﻿Public Class frmConf

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        My.Settings.ID = txtID.Text
        My.Settings.URL = txtURL.Text
        My.Settings.Paste = chkPaste.Checked
        My.Settings.Alt = chkAlt.Checked
        My.Settings.Ctrl = chkCtrl.Checked
        My.Settings.Win = chkWin.Checked
        My.Settings.Shift = chkSh.Checked
        My.Settings.HotKey = ComboBox1.SelectedValue
        My.Settings.EnableSendKeys = chkSendKeys.Checked
        My.Settings.KeysToSend = txtKeysToSend.Text
        My.Settings.PasteWordURL = chkPasteWordURL.Checked


        My.Settings.Configured = True

        My.Settings.NativeID = txtNativeID.Text
        My.Settings.NativeURL = txtNativeURL.Text
        My.Settings.NativePaste = chkNativePaste.Checked
        My.Settings.NativeAlt = chkNativeAlt.Checked
        My.Settings.NativeCtrl = chkNativeCtrl.Checked
        My.Settings.NativeWin = chkNativeWin.Checked
        My.Settings.NativeShift = chkNativeSh.Checked
        My.Settings.NativeHotKey = ComboBox2.SelectedValue
        My.Settings.NativeEnableSendKeys = chkNativeSendKeys.Checked
        My.Settings.NativeKeysToSend = txtNativeKeysToSend.Text
        My.Settings.NativePasteWordURL = chkNativePasteWordURL.Checked

        My.Settings.NativeConfigured = True
        My.Settings.Save()

        Me.Close()


    End Sub

    Private Sub AsignValues()

        txtID.Text = My.Settings.ID
        txtURL.Text = My.Settings.URL
        chkPaste.Checked = My.Settings.Paste
        chkAlt.Checked = My.Settings.Alt
        chkCtrl.Checked = My.Settings.Ctrl
        chkWin.Checked = My.Settings.Win
        chkSh.Checked = My.Settings.Shift
        chkSendKeys.Checked = My.Settings.EnableSendKeys
        txtKeysToSend.Text = My.Settings.KeysToSend
        chkPasteWordURL.Checked = My.Settings.PasteWordURL

        If ComboBox1.Items.IndexOf(CType(Val(My.Settings.HotKey), Keys)) >= 0 Then

            ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(CType(Val(My.Settings.HotKey), Keys))

        End If

        txtNativeID.Text = My.Settings.NativeID
        txtNativeURL.Text = My.Settings.NativeURL
        chkNativePaste.Checked = My.Settings.NativePaste
        chkNativeAlt.Checked = My.Settings.NativeAlt
        chkNativeCtrl.Checked = My.Settings.NativeCtrl
        chkNativeWin.Checked = My.Settings.NativeWin
        chkNativeSh.Checked = My.Settings.NativeShift
        chkNativeSendKeys.Checked = My.Settings.NativeEnableSendKeys
        txtNativeKeysToSend.Text = My.Settings.NativeKeysToSend
        chkNativePasteWordURL.Checked = My.Settings.NativePasteWordURL

        If ComboBox2.Items.IndexOf(CType(Val(My.Settings.NativeHotKey), Keys)) >= 0 Then

            ComboBox2.SelectedIndex = ComboBox2.Items.IndexOf(CType(Val(My.Settings.NativeHotKey), Keys))

        End If


    End Sub

    Private Sub frmConf_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ComboBox1.DataSource = System.Enum.GetValues(GetType(Keys))
        ComboBox2.DataSource = System.Enum.GetValues(GetType(Keys))

        AsignValues()


    End Sub

    Private Sub btnDefaultsBABYLON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDefaultsBABYLON.Click
        My.Settings.Reset()
        AsignValues()
    End Sub
End Class